#pragma once

#include "OperationTemplateParameter.h"

#include "Operation.h"

namespace uml {

OperationTemplateParameter::OperationTemplateParameter(const QString& umlType)
    : TemplateParameter(umlType) {}

void OperationTemplateParameter::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    TemplateParameter::fromJson(json, errorList);
    parameteredElement_ = JsonSerializable::create<Operation>(json.value("parameteredElement"), errorList);

}

void OperationTemplateParameter::toJson(QJsonObject& json) {
    TemplateParameter::toJson(json);
    if (parameteredElement_) {
        QJsonObject parameteredElement_json;
        parameteredElement_->toJson(parameteredElement_json);
        json.insert("parameteredElement", parameteredElement_json);
    }
}

/// <summary>
/// parameteredElement getter
/// The Operation exposed by this OperationTemplateParameter.
/// </summary>
shared_ptr<Operation> OperationTemplateParameter::parameteredElement() const {
    return parameteredElement_;
}

/// <summary>
/// parameteredElement setter
/// The Operation exposed by this OperationTemplateParameter.
/// </summary>
void OperationTemplateParameter::setParameteredElement(shared_ptr<Operation> value) {
    parameteredElement_ = value;
}

} // namespace uml
